﻿// JScript File
//this function is used to check whether value has been selected from dropdown or not
function IsSelected(obj)
{
//alert(obj.options.selected.value);
    //if (obj.options.selected.value
}
//this function is used to populate Sales Mangers  corresponds to Branch
function SelectSaleManager(objBranch,objSalesMgr)
{
// ON selection of category this function will work


removeAllOptions(objSalesMgr);

addOption(objSalesMgr, "", "---Select---","");

if(objBranch.value == 'Mumbai')
{

addOption(objSalesMgr,"Aalok B", "Aalok B");
addOption(objSalesMgr,"Ravi S", "Ravi S");
}
if(objBranch.value == 'Pune')
{
addOption(objSalesMgr,"Sheetal B", "Sheetal B");
}
if(objBranch.value == 'Delhi')
{
addOption(objSalesMgr,"Sanjeev", "Sanjeev");
}
if(objBranch.value == 'Nasik')
{
addOption(objSalesMgr,"Rajesh G", "Rajesh G");
}

if(objBranch.value == 'Lucknow')
{
addOption(objSalesMgr,"Rahul C", "Rahul C");
}


}
function removeAllOptions(selectbox)
{

	var i;
	for(i=selectbox.options.length-1;i>=0;i--)
	{
	    if (selectbox.value!='');
		selectbox.remove(i);
	}

}
function addOption(selectbox, value, text )
{
	var optn = document.createElement("OPTION");
	optn.text = text;
	optn.value = value;

	selectbox.options.add(optn);
}


//this function is used to populate agent corresponds to IntermediadryType
function SelectAgent(objIntermediaryType,objAgent)
{


removeAllOptions(objAgent);

addOption(objAgent, "", "---Select---","");

if(objIntermediaryType.value == 'Banks')
{

addOption(objAgent,"ICICI", "ICICI");
addOption(objAgent,"Citi Bank", "Citi Bank");
}
if(objIntermediaryType.value == 'Agents')
{
addOption(objAgent,"Rajeev B", "Rajeev B");
addOption(objAgent,"IPCD", "IPCD");

}
if(objIntermediaryType.value == 'WebWorld')
{
addOption(objAgent,"Sanjeev", "Sanjeev");
}
if(objIntermediaryType.value == 'CSO')
{
addOption(objAgent,"Rajesh G", "Rajesh G");
}

if(objIntermediaryType.value == 'Brokers')
{
addOption(objAgent,"Ram V", "Ram V");
addOption(objAgent,"Raj S", "Raj S");
}
}

function GetNextHKITNumber(objToHkit,objFromHkit)
{
    if (objToHkit.value!='')
    objFromHkit.value = parseInt(objToHkit.value)+1
    else
    objFromHkit.value ='';
}

//Alert User if all checkbox on Page is unchecked
function IsCheckboxChecked(oSrc, args)
{
 args.IsValid = true;
 var elem = document.forms[0].elements;
 var result = 0 ;
 
  for(var i=0;i<elem.length;i++)
    {
      if(elem[i].type == "checkbox")
	    {
	        checkboxPresent = 1;
		  
		    if(elem[i].checked == true)
		    { 
		        result = result + 1;
		    }
	    }
    }
  
    if(result == 0)
     {
        args.IsValid = false;
     }
}

//Returns Text After Trimming it
function Trim(str)
{  
 
  //Remove Leading Space
  while(str.charAt(0) == (" ") )
  {  str = str.substring(1);
  }
  //Remove Preceding Space
  while(str.charAt(str.length-1) == " " )
  {  str = str.substring(0,str.length-1);
  }
 
  return str;
}

//Alert User if all Combobox Unchecked
function IsComboboxDefault(oSrc, args)
{
 
 args.IsValid = true;
 var elem = document.forms[0].elements;
 var result = 0 ;

  for(var i=0;i<elem.length;i++)
    {
      if (elem[i].type == "select-one")
        {
		    if(elem[i].value != "--- Select ---")
		    {
		        result = result + 1;
		    }
	    }
    }
   
   if(result == 0)
   {
    args.IsValid = false;
   }
}

//Alert User if all Textbox Empty
function IsTextboxDefault(oSrc, args)
{
 
 args.IsValid = true;
 var elem = document.forms[0].elements;
 var result = 0 ;

  for(var i=0;i<elem.length;i++)
    {
	    if ( elem[i].type == "text" )
	    {
	        //Include JScript Function "Trim" 
		    if(Trim(elem[i].value) != "")
		    {
		        result = result + 1;
		    }
		    
		    ////Without JScript Function "Trim" 
		    //if(elem[i].value != "")
		    //{
		    //    result = result + 1;
		    //}
	    }
    }
   
   if(result == 0)
   {
    args.IsValid = false;
   }
}




